package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author 喵喵喵
 * Date 2025/6/5 16:15
 */
@Mapper
public interface DishMapper {
    @Select("SELECT * FROM dish WHERE category_id = #{categoryId}")
    List<Dish> getDishListByCategoryId(Integer categoryId);

    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    Page<DishVO> page(DishPageQueryDTO dto);

    @Select("select * from dish where id=#{id}")
    Dish getDishById(Long id);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @Select("SELECT * FROM dish WHERE category_id = #{categoryId}")
    List<Dish> getDishesByCategoryId(Integer id);


    List<Dish> list(Dish dish);
}
